import { Entity, PrimaryGeneratedColumn, Column, CreateDateColumn, UpdateDateColumn, OneToMany } from 'typeorm';
import { Exclude } from 'class-transformer';

@Entity('users')
export class User {
  @PrimaryGeneratedColumn()
  id: number;

  @Column({ length: 50, nullable: false })
  username: string;

  @Column({ length: 50, nullable: true })
  nickname: string;

  @Column({ length: 11, nullable: false })
  phone: string;

  @Exclude()
  @Column({ length: 100 })
  password: string;

  @Column({ length: 255, nullable: true })
  avatar: string;

  @Column({ length: 100, nullable: true })
  email: string;

  @Column({ type: 'text', nullable: true })
  bio: string;

  @Column({ type: 'tinyint', default: 0 })
  gender: number;

  @Column({ type: 'varchar', length: 20, nullable: true })
  birthday: string;

  @Column({ length: 50, nullable: true })
  province: string;

  @Column({ length: 50, nullable: true })
  city: string;

  @Column({ type: 'tinyint', default: 1 })
  status: number;

  @Column({ default: false })
  isPhoneVerified: boolean;

  @Column({ default: false })
  isEmailVerified: boolean;

  @Column({ length: 50, nullable: true })
  lastLoginIp: string;

  @Column({ nullable: true })
  lastLoginAt: Date;

  @CreateDateColumn()
  createdAt: Date;

  @UpdateDateColumn()
  updatedAt: Date;

}

